﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class ybqy_print_fengmian : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from a01000 where  qiyeid=" + Session["qiyeid"], sqlcon);
        string tempp = "select * from a01000 where sbnd='" + DateTime.Now.Year.ToString() + "' and qiyeid=" + Session["qiyeid"];
        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

        if (!IsPostBack)
        {
            if (reader.Read())
            {   //先判断是否有今年的
                tempp = "select * from a01000 where sbnd='" + DateTime.Now.Year.ToString() + "' and qiyeid=" + Session["qiyeid"];
                reader.Close();
                sqlcon.Open();
                sqlcmd.CommandText = tempp;
                reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);
                if (reader.Read())
                {
                    TextBox1.Text = reader["sbdjdm"].ToString();
                    TextBox4.Text = reader["dwmc"].ToString();
                    TextBox5.Text = reader["fddbr"].ToString();
                    TextBox6.Text = reader["tbr"].ToString();
                    TextBox7.Text = reader["sbdwfrdm"].ToString();
                    TextBox8.Text = reader["bcrqnian"].ToString();
                    TextBox9.Text = reader["bcrqyue"].ToString();
                    TextBox10.Text = reader["bcrqri"].ToString();
                }
            }
        }
        reader.Close();

        SqlCommand sqlcmd1 = new SqlCommand("select qhdm from system_status", sqlcon);
        sqlcon.Open();
        TextBox3.Text = sqlcmd1.ExecuteScalar().ToString();
        TextBox2.Text = DateTime.Now.Year.ToString();
        TextBox8.Text = DateTime.Now.Year.ToString();
        TextBox9.Text = DateTime.Now.Month.ToString();
        TextBox10.Text = DateTime.Now.Day.ToString();

        
        reader.Close();
        sqlcon.Close();

    }
}